/* login.js */
import IMService from '../../static/lib/imservice.js';
const app = getApp()
Page({
	data: {
		username:"",
		password:"",
		showError:false,
	},
	login: function(e) {
		// 将IMService定义为全局变量
		var service = app.globalData.imService = new IMService();
		var username = e.detail.value.username;
		var password = e.detail.value.password;
		if (username.trim() != "" && password.trim() != "") {
			if (service.login(username, password)) {
				service.connectIM();
				wx.redirectTo({
					url: '../contacts/contacts'
				})
				return;
			}
		}
		this.setData({
			showError:true
		});
	}
})